/**
 * Below is a sample adapter for connecting with a webservice.
 */

var myRemoteAdapterGaragesaleItem={
    server:BASE_URL,
    save:function(obj,callback,foo){
        $.get(this.server+"todo.php?axt=save&data="+encodeURIComponent(JSON.stringify(obj)),
            function(id){
                obj.id=id;
                $(document).trigger(obj.name + ":save", obj);
                if(callback)
                    callback(obj);
            }
        );
    },
    fetch:function(item,callback){
        $.get(BASE_URL+"garagesale_item?id="+encodeURIComponent(item.id),
            function(obj){
                obj=JSON.parse(obj);
                if(callback) {
                    callback(obj);
                }
            }
        );
    },
    fetchAll:function(item,callback){
        $.get(BASE_URL+"garagesale_items?id="+encodeURIComponent(item.id),
            function(obj){
                obj=JSON.parse(obj);
                if(callback)
                    callback(obj);
            }
        );
    },
    remove:function(obj,callback){
        $.get(this.server+"todo.php?axt=delete&data="+encodeURIComponent(obj.id),
            function(obj){
                $(document).trigger(obj.name + ":remove", obj.id);
                obj=JSON.parse(obj);
                if(callback)
                    callback(obj);
            }
        );
    }
}


Garagesale_item =  $.mvc.model.extend("garagesale_item",{
    validate:function(opts){
        if(opts&&opts.trigger)
            return "error validating";
        return true;
    },
    itemID: '',
    itemAlbumID: '',
    itemTitle: '',
    itemParentCat: '',
    itemSubCat: '',
    itemPrice: '',
    itemBrand: '',
    itemLocation: '',
    itemDimensions: '',
    itemCondition: '',
    itemDescription: '',
    itemCreated: '',
    itemStatus: '',
    albumID: '',
    albumTitle: '',
    dateCreated: '',
    status: '',
    userID: '',
    images: []
}, myRemoteAdapterGaragesaleItem);

var garagesale_item = new Garagesale_item();